package com.zhao.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhao.mapper.RoleMapper;
import com.zhao.pojo.Role;
import com.zhao.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Override
    public void savePerms(String[] ids, String rid) {
        if (ids==null) {
            roleMapper.delsPerms(rid);
        }else {
            roleMapper.delsPerms(rid);
            roleMapper.savePerms(ids,rid);
        }

    }

    @Override
    public List<String> checkedList(Integer rid) {
        return roleMapper.checkedList(rid);
    }
    //删除角色
    @Override
    public void delRole(String id) {
        roleMapper.delsPerms(id);
        roleMapper.deleteById(Integer.parseInt(id));
    }

    @Override
    public String getUserRoleName(Integer userId) {
        return roleMapper.getUserRoleName(userId);
    }
}
